#include<iostream>
using namespace std;
const int N = 1e3 + 10;
int primes[N];
int cnt;
bool st[N];
int n, k;
bool prime(int x)
{
	for (int i = 2; i <= x / i; i++) {
		if (x % i == 0)return 0;
	}
	return 1;
}
void fun()
{
	for (int i = 2; i <= N; i++) {
		if (!st[i]) {
			//cout<<"11"<<endl;
			primes[++cnt] = i;
			//cout << primes[cnt] << " ";
			for (int j = i * 2; j <= N; j += i) {
				st[j] = 1;
			}
		}
	}
}
int main()
{
	fun();
	//cout<<1<<endl;
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> k;
		int ans = 0;
		int temp = n;
		/*for (int i = 1; i <= cnt && primes[i + 1] <= n; i++,temp--) {
			if (primes[i] + primes[i + 1] == temp - 1) {
				ans++;
			}
		}*/
		//cout<<"ans=="<<ans<<endl;
		for (; temp >= 1; temp--) {
			if (!prime(temp))continue;
			for (int i = 1; i <= cnt && primes[i + 1] <= temp; i++) {
				if (primes[i] + primes[i + 1] == temp - 1) {
					//cout<<"bug"<<primes[i]<<"  "<<primes[i+1]<<endl;
					ans++;
				}
			}
		}
		//cout<<ans<<endl;
		if (ans >= k)puts("YES");
		else puts("NO");
	}
	return 0;
}